<!DOCTYPE html>
<html lang="zh-cn">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Notebook</title>
  <!-- Icons & Stylesheets -->
  <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
  <link rel="stylesheet" href="style.css" />
</head>

<body>
  <!-- Include the library in the page -->
  <script src="https://cdn.staticfile.org/vue/2.6.10/vue.js"></script>
  <script src="https://cdn.staticfile.org/marked/0.6.2/marked.js"></script>
  <script src="https://cdn.staticfile.org/moment.js/2.24.0/moment.js"></script>
  <!-- Notebook app -->
  <div id="notebook">
    <aside class="side-bar">
      <div class="toolbar">
        <button @click="addNote" :title="notes.length + ' note(s) already'"><i class="material-icons">add</i>Add
        note</button>
      </div>
      <div class="notes">
        <div class="note" 
          v-for="note of sortedNotes" 
          @click="selectNote(note)" 
          :class="{selected: note === selectedNote}"
        >
        <i class="icon material-icons" v-if="note.favorite">star</i>
        {{note.title}}</div>
      </div>
    </aside>

    <template v-if="selectedNote">
      <!-- Main pane -->
      <section class="main">
        <div class="toolbar">
          <input v-model="selectedNote.title" placeholder="Note title">
          <button @click="removeNote" title="Remove note">
          <i class="material-icons">delete</i>
        </button>
        <button @click="favoriteNote" title="Favorite note">
          <i class="material-icons">
            {{selectedNote.favorite ? 'star' : 'star_border'}}
          </i>
        </button>
        </div>
        
        <textarea v-model="selectedNote.content"></textarea>

        <div class="toolbar status-bar">
          <span class="date">
            <span class="label">Created</span>
            <span class="value">{{selectedNote.created | date}}</span>
          </span>
          <span class="lines">
            <span class="label">Lines</span>
            <span class="value">{{linesCount}}</span>
          </span>
          <span class="words">
            <span class="label">Words</span>
            <span class="value">{{wordsCount}}</span>
          </span>
          <span class="characters">
            <span class="label">Characters</span>
            <span class="value">{{charactersCount}}</span>
          </span>
        </div>
      </section>

      <!-- Preview pane -->
      <aside class="preview" v-html="notePreview">
      </aside>
    </template>


  </div>

  <!-- Some JavaScript -->
  <script src="script.js"></script>
</body>

</html>